package drivers

import (
	"fmt"
	`gitee.com/vrv_media/go-micro-framework/pkg/dao/oscar`
	"gorm.io/gorm"
)

// NewShentongDialector 创建mysql数据库驱动
func NewShentongDialector(host, userName, password, database string, port int) gorm.Dialector {
	dsn := BuildShentongDsn(host, userName, password, database, port)
	fmt.Println("神通数据库连接信息dsn：", dsn)
	return oscar.Open(dsn)
}

func BuildShentongDsn(host, userName, password, database string, port int) string {
	//return "sysdba/szoscar55@158.100.3.56:20003/osrdb"
	return fmt.Sprintf("%s/%s@%s:%d/%s", userName, password, host, port, database)
	//return fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=utf8mb4&parseTime=True&loc=Local", userName, password, host, port, database)
}
